{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                    <!--<div class="layui-input-inline" style="margin-top: 5px">-->
                    <!--<input type="text"  name="start" onfocus="wk.lay_date(this);" class="layui-input layer-date search" placeholder="开始时间"/>-->
                    <!--</div>-->

                    <!--<div class="layui-input-inline" style="margin-top: 5px">-->
                    <!--<input type="text"  name="end" onfocus="wk.lay_date(this);" class="layui-input layer-date search" placeholder="结束时间"/>-->
                    <!--</div>-->

                    <!--<div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">-->
                    <!--<input type="text" id="keyword" class="layui-input search" name="keyword" value="" placeholder="标题"/>-->
                    <!--</div>-->
                    <!--<div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">-->
                    <!--<select name="province" lay-search="" id="province"  lay-filter="province">-->
                    <!--<option value="">全部</option>-->
                    <!--<option value="1" >上架中</option>-->
                    <!--<option value="2" >已下架</option>-->
                    <!--</select>-->
                    <!--</div>-->
                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" id="name" class="layui-input search" name="name" value="" placeholder="学校名字" style="margin-top: 5px" />
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="province" lay-search="" id="province"  lay-filter="province">
                                <option value="">---- 请选择省 ----</option>
                                {foreach name="province" item="vo"}
                                <option value="{$vo.district_id}" >{$vo.district}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="city" lay-search=""  id="city"  lay-filter="city">
                                <option value="">---- 请选择市 ----</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="district" lay-search=""  id="district"  lay-filter="district">
                                <option value="">---- 请选择区 ----</option>
                            </select>
                        </div>

                    <div class="layui-input-inline" style="margin-top: 5px">
                    <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                    <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                    </div>
                    </div>
                    <div class="col-sm-12">
                        <div class="input-group" >
                            <input type="text" disabled class="layui-input" id="tongji1" value="编辑禁止年份的时候如有多个务必以英文逗号隔开，如：2018,2019（不能是：2018，2019）" style="border:1px solid red;color: red;width: 700px;" />
                        </div>
                    </div>
                </div>

                <div class="col-sm-12">
                    <div class="input-group" >
                        <!--<button class="btn btn-primary" type="button" onclick="wk.href('{:url('add')}');">-->
                        <!--<i class="fa fa-plus"></i> 添加-->
                        <!--</button>-->
                        <!--<button class="btn btn-primary" type="button" onclick="wk.href('{:url('unbookAdd')}');" style="margin-left: 5px">-->
                        <!--<i class="fa fa-plus"></i> 添加非图书-->
                        <!--</button>-->

                        <!--<button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
                        <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                        <!--</button>-->
                        <!--<ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">-->
                        <!--&lt;!&ndash;<li><a href="javascript:;" class="layuiBtn" data-type="getCheckData"><i class="fa fa-trash-o"></i> 批量删除 </a></li>&ndash;&gt;-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="usingAllS"><i class="fa fa-check-circle"></i> 批量上架</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="batchForbiddenS"><i class="fa fa-ban"></i> 批量下架</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 批量导出</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>-->
                        <!--</ul>-->
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <!--<div class="col-sm-12">-->
                <!--<div class="input-group" >-->
                <!--<button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
                <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                <!--</button>-->
                <!--<ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">-->
                <!--<li><a href="javascript:;" class="layuiBtn" data-type="excelIn"><i class="fa fa-check-circle"></i> 批量导入 </a></li>-->
                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="usingAllS"><i class="fa fa-ban"></i> 批量上架</a></li>-->
                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="batchForbiddenS"><i class="fa fa-trash-o"></i> 批量下架</a></li>-->
                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="batchDel"><i class="fa fa-trash-o"></i> 批量删除</a></li>-->
                <!--&lt;!&ndash;<li><a  href="javascript:;" class="layuiBtn" data-type="excelIn"><i class="fa fa-external-link"></i> 批量导入</a></li>&ndash;&gt;-->
                <!--</ul>-->
                <!--</div>-->
                <!--</div>-->
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>
                    <!--状态显示模板-->
                    <script type="text/html" id="staBar">
                        <input type="checkbox" value="{{d.school_id}}"  lay-skin="switch"  lay-text="所有年份|当前年份" lay-filter="OnOff" {{ d.school_history == 2 ? 'checked' : '' }}  >
                    </script>
                    <script type="text/html" id="staBar2">
                        <input type="checkbox" value="{{d.school_id}}"  lay-skin="switch"  lay-text="开启|关闭" lay-filter="OnOff2" {{ d.school_change == 2 ? 'checked' : '' }}  >
                    </script>
                    <script type="text/html" id="staBar3">
                        <input type="checkbox" value="{{d.school_id}}"  lay-skin="switch"  lay-text="正常|冻结" lay-filter="OnOff3" {{ d.school_status == 1 ? 'checked' : '' }}  >
                    </script>
                    <!--修改状态模板-->
                    <!--<script type="text/html" id="staBar">-->
                    <!--<input type="checkbox" value="{{d.school_id}}"  lay-skin="switch"  lay-text="上架中|已下架" lay-filter="OnOff" {{ d.school_status == 1 ? 'checked' : '' }} >-->
                    <!--</script>-->

                    <!--状态显示模板-->

                    <!--<script type="text/html" id="banner_status">-->
                    <!--{{# if(d.banner_status == 1){ }}-->
                    <!--上架中-->
                    <!--{{# } }}-->
                    <!--{{# if(d.banner_status == 2){ }}-->
                    <!--已下架-->
                    <!--{{# } }}-->
                    <!--</script>-->
                    <script type="text/html" id="opeBar">
                        <!--<a href="javascript:;" onclick="wk.layer_show('统购配置','{:url('tong')}?school_id={{d.school_id}}')" class="btn btn-primary btn-xs m-r-xs" title="统购配置">统购配置</a>-->
                        <a href="javascript:;" onclick="wk.layer_show('查看年级','{:url('tong')}?school_id={{d.school_id}}')" class="btn btn-primary btn-xs m-r-xs" title="统购配置">统购配置</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("school/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
//            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type:'numbers', width: 80, title: '序号'}
                , {field: 'school_id', width: 50, title: 'ID', align: 'center'}
                , {field: 'school_name', width: 200, title: '学校名称', align: 'center'}
//                , {field: 'school_status_name', width: '', title: '是否下架', align: 'center'}
                , {field: 'school_address', width: '', title: '省市区', align: 'center'}
                , {field: 'school_no_years', width: '', title: '禁止年份', align: 'center', edit: 'test'}
                , {field: 'school_history',fixed: 'right', width: '', title: '是否展示当前年份', align: 'center', templet: '#staBar'}
                , {field: 'school_change',fixed: 'right', width: '', title: '是否开启现场调换', align: 'center', templet: '#staBar2'}
                , {field: 'school_status',fixed: 'right', width: '', title: '学校状态', align: 'center', templet: '#staBar3'}
                , {fixed: 'right', width: 100, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.layui-cricle').viewer();//图片查看器
            }
        });
        //监听单元格编辑---排序
        table.on('edit(testReload)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            wk.change(data.school_id,"{:url('updateSort')}",field,value);
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 2: num = 1;
            //用户状态
            wk.status(this.value,num, '{:url("changeSchoolShow")}',obj);
        });
        form.on('switch(OnOff2)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 2: num = 1;
            //用户状态
            wk.status(this.value,num, '{:url("changeSchoolChange")}',obj);
        });
        form.on('switch(OnOff3)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 1: num = 2;
            //用户状态
            wk.status(this.value,num, '{:url("changeSchoolStatus")}',obj);
        });
        //批量操作
        var $ = layui.$, active = {
            //批量删除
            batchDel:function () {
                wk.batchDel(getIds(),"{:url('del')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['s_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>